from ...pipeline.Node import Node
import numpy as np
import seaborn as sns
import parselmouth
from parselmouth.praat import call
import matplotlib.pyplot as plt

from .VoicelabNode import VoicelabNode

from Voicelab.toolkits.Voicelab.VisualizeVoiceNode import VisualizeVoiceNode


###################################################################################################
# VISUALIZE VOICE NODE
# WARIO pipeline node for visualizing a voice as a spectrogram.
###################################################################################################
# ARGUMENTS
# 'voice'   : sound file generated by parselmouth praat
###################################################################################################
# RETURNS
###################################################################################################

node = VisualizeVoiceNode()
node.args['file_path'] = '/home/david/Desktop/Sderfahrer_mHK66.wav'
node.args['voice'] = parselmouth.Sound(node.args['file_path'])
node.args['window_length'] = 0.05
node.args['colour_map'] = 'afmhot'  # gist_yarg, gist_heat, gist_rainbow, gist_stern, jet, nipy_spectral, rainbow, prism, gist_ncar
node.show_figure = True
# self.plot_formants(formants_axis, formants, voice)
results = node.process()
axis = results['figure'].get_axes()[0]
voice = node.args["voice"]
pitch = voice.to_pitch()
pad_distance = 10
formants = node.args['voice'].to_formant_burg()
intensity = voice.to_intensity()
node.plot_formants(axis, formants, voice)
node.plot_pitch(axis, pitch, voice, pad_distance)
node.plot_intensity(axis, intensity, pad_distance)
results['figure'].show()